package webgamemaker.RPGMakerVXLoader;

import java.util.ArrayList;

import webgamemaker.Common.AutoTile;
import webgamemaker.Common.Callback;
import webgamemaker.Common.Tile;
import webgamemaker.Common.TileData;
import webgamemaker.Common.TileSet;

public class TileSetA4 extends TileSet {

	public TileSetA4(String filename) {
		super(filename, 32, 32);
		addLoadCallback(new LoadCallback());
	}
	
	public class LoadCallback implements Callback
	{
		public void onCall(Object src) 
		{
			ArrayList<TileData> tiles = new ArrayList<TileData>();
			for(int i = 0; i < 48; i++)
			{
				if((i%16)/8 == 0)
				{
					Tile tab[] = new Tile[6];
					for(int j = 0; j < 6; j++)
						tab[j] = TileSetA4.this.tiles.get((j%2)+(j/2)*16+(i%8)*2+(i/16)*80).tile;
					tiles.add(new TileData(new AutoTile(tab)));
				}
				else
				{
					Tile tab[] = new Tile[4];
					for(int j = 0; j < 4; j++)
						tab[j] = TileSetA4.this.tiles.get((j%2)+(j/2)*16+(i%8)*2+(i/16)*80+48).tile;
					tiles.add(new TileData(new AutoTile(tab)));
				}
			}
			TileSetA4.this.tiles = tiles;
		}
	}

}
